#!/usr/bin/env python3
# -*- coding: utf-8 -*-

'使用GET模仿iPhone访问豆瓣'
from urllib import request

req = request.Request('http://www.douban.com/')
req.add_header('User-Agent','Mozilla/6.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/8.0 Mobile/10A5376e Safari/8536.25')
with request.urlopen(req) as response:
    data = response.read()
    print('Status:',response.status,response.reason)
    for k, v in response.getheaders():
        print('%s:%s' % (k, v))
    print('Data:',data.decode('utf-8'))